﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.YWDF
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.YWDF;

    public class ywdf_order_Map : ClassMapping<ywdf_order>
    {
        public ywdf_order_Map()
        {
            Id(x => x.id, map =>
            {
                map.Length(40);
                map.Column(ywdf_order.Columns.id);
            });
            Property(x => x.is_valid, map => map.Column(ywdf_order.Columns.is_valid));
            Property(x => x.create_date, map => map.Column(ywdf_order.Columns.create_date));

            Property(x => x.confirm_date, map =>
            {
                map.Column(ywdf_order.Columns.confirm_date);
                map.NotNullable(false);
            });
            Property(x => x.confirm_describe, map =>
            {
                map.Column(ywdf_order.Columns.confirm_describe);
                map.NotNullable(false);
                map.Length(10000);
            });
            Property(x => x.order_date, map => map.Column(ywdf_order.Columns.order_date));
            Property(x => x.order_date_bgn, map => map.Column(ywdf_order.Columns.order_date_bgn));
            Property(x => x.order_date_end, map => map.Column(ywdf_order.Columns.order_date_end));
            Property(x => x.order_describe, map =>
            {
                map.Column(ywdf_order.Columns.order_describe);
                map.Length(10000);
            });

            //订房所属项目
            ManyToOne(x => x.order_project, map =>
            {
                map.Column(ywdf_order.Columns.order_project_id);
                map.NotNullable(false);
            });

            //订房所属部门
            ManyToOne(x => x.order_department, map =>
            {
                map.Column(ywdf_order.Columns.order_department_id);
                map.NotNullable(false);
            });

            //订房用户
            ManyToOne(x => x.order_user, map =>
            {
                map.Column(ywdf_order.Columns.order_user_id);
                map.NotNullable(false);
            });

            //确认用户
            ManyToOne(x => x.confirm_user, map =>
            {
                map.Column(ywdf_order.Columns.confirm_user_id);
                map.NotNullable(false);
            });

            //关联订房房间详细记录
            Bag(x => x.details, map => map.Key(km => km.Column(ywdf_order_detail.Columns.order_id)), act => act.OneToMany());

            Table(ywdf_order.TableName);

            //不进行创建
            SchemaAction(NHibernate.Mapping.ByCode.SchemaAction.None);
        }
    }
}
